package com.servlet02;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/my")
public class TestServlet extends HttpServlet {

    /**
     * http请求有很多种，常用的有4：
     * GET(读取)、POST(保存)、PUT(修改)、DELETE(删除)
     */
    @Override
    // 处理GET请求
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write("hello,world");
    }

    @Override
    // 处理POST请求
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write("POST");
    }
}
